package com.jic.order.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.order.entity.OrderInvoice;
import com.jic.order.entity.OrderMark;
import com.jic.order.mapper.OrderInvoiceMapper;
import com.jic.order.mapper.OrderMarkMapper;
import com.jic.order.request.OrderMarkRequest;
import com.jic.order.service.OrderInvoiceService;
import com.jic.order.service.OrderMarkService;
import com.jic.order.utils.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单附件及备注
 *
 * @author :
 * @version : v1.0.0
 * @email :
 * @since : 2020-03-03 11:14:45
 */
@Service
@Slf4j
public class OrderMarkServiceImpl implements OrderMarkService {

    @Autowired
    private OrderMarkMapper orderMarkMapper;

    @Override
    public RestResult saveMarkData(OrderMarkRequest orderMarkRequest) {
        log.info("开始进入订单附件保存-------》" + orderMarkRequest.toString());

        try {
            //修改
            if (orderMarkRequest.getId() != null) {
                OrderMark orderMark = new OrderMark();
                BeanUtils.copyProperties(orderMarkRequest, orderMark);
                orderMarkMapper.update(orderMark);
            } else {
                OrderMark orderMark = new OrderMark();
                BeanUtils.copyProperties(orderMarkRequest, orderMark);
                orderMarkMapper.insert(orderMark);
            }
        } catch (Exception e) {
            log.error("saveMarkData============>" + e);
            return RestResult.error("9999", e.getLocalizedMessage());
        }
        return RestResult.success(true);
    }

}
